<div id="pages_menu_list_list" class="scroll" style="height:100%;display:none;"><master title="菜单管理">
  <div class="addFirst addDiv">
    <span class="btn add" data-index="" @click="add">+ 一级菜单</span>
  </div>
  <div v-for="(item,index) in tree" key="id" class="list">
    <div class="itemDiv">
      <div v-if="item.children.length" class="arrow" :data-index="index" @click="change">
        <img class="arrowImg" v-if="item.opened" src="/images/arrow_grey_down.png"></img>
        <img class="arrowImg" v-else src="/images/arrow_grey_right.png"></img>
      </div>
      <span v-else class="arrowHide"></span>
      <span class="itemName">{{item.name}}</span>
      <span v-if="item.editAble == 1" class="btn" :data-index="index" @click="edit">编辑</span>
      <span v-if="item.editAble == 1 && !item.children.length" class="btn delet" :data-index="index" @click="delet">删除</span>
    </div>
    <div v-if="item.opened" class="listChild">
      <div v-if="item.children.length" key="id" v-for="(item1,index1) in item.children">
        <div class="itemDiv">
          <div v-if="item1.children.length" class="arrow" :data-index="index + ',' + index1" @click="change">
            <img class="arrowImg" v-if="!item1.opened" src="/images/arrow_grey_down.png"></img>
            <img class="arrowImg" v-else src="/images/arrow_grey_right.png"></img>
          </div>
          <span v-else class="arrowHide"></span>
          <span class="itemName">{{item1.name}}</span>
          <span class="btn" v-if="item1.editAble == 1" :data-index="index + ',' + index1" @click="edit">编辑</span>
          <span v-if="item1.editAble == 1 && !item1.children.length" class="btn delet" :data-index="index + ',' + index1" @click="delet">删除</span>
        </div>
        <div v-if="!item1.opened" class="listChild">
          <div v-for="(item2,index2) in item1.children" key="id">
            <div class="itemDiv">
              <span class="arrowHide"></span>
              <span class="itemName">{{item2.name}}</span>
              <span class="btn" v-if="item2.editAble == 1" :data-index="index + ',' + index1 + ',' + index2" @click="edit">编辑</span>
              <span class="btn delet" v-if="item2.editAble == 1" :data-index="index + ',' + index1 + ',' + index2" @click="edit">删除</span>
            </div>
          </div>
          <div v-if="item1.editAble == 1" class="addDiv">
            <span class="arrowHide"></span>
            <span class="btn add" :data-index="index + ',' + index1" @click="add">+ {{item1.name}}子菜单</span>
          </div>
        </div>
      </div>
      <div v-if="item.editAble == 1" class="addDiv">
        <span class="arrowHide"></span>
        <span class="btn add" :data-index="index" @click="add">+ {{item.name}}子菜单</span>
      </div>
    </div>
  </div>
</master></div>
<script type="text/javascript">
(function (G) {
  G.vue("pages_menu_list_list",{
  "usingComponents": {
    "master": "/components/Master/Master"
  }
},G.classifyList({
    modelName:'menu',
    nickName:'菜单'
  },{
    methods:{
      getList: function () {
        var _this = this,userInfo = G.Storage.get('userInfo');
        Y.ajax('/api/model/menu', function (ret) {
          if (!ret.errorMsg) {
            var tree = {
              '0': {
                children: []
              }
            };
            for (var i = 0; i < ret.length; i++) {
              ret[i].parentId = ret[i].parentId || '0';
              ret[i].opened = true;
              ret[i].children = [];
              tree[ret[i].id] = ret[i];
              if (tree[ret[i].parentId]) tree[ret[i].parentId].children.push(ret[i])
            }
            _this.setData({
              tree: tree['0'].children
            })
          }
        },{
          data:{
            sql:'classifySort',
            unitId:userInfo.unitId
          }
        })
      }
    }
  }))
})(Y)
</script>